﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Move : MonoBehaviour
{
    public float speed = 5f; 
    private GameObject camer;

    private CharacterController characterController;

    // Use this for initialization
    void Start()
    {
        camer = this.gameObject;
        characterController = camer.AddComponent<CharacterController>();
    }

    // Update is called once per frame
    void Update()
    {
        Vector3 forward = camer.transform.TransformDirection(Vector3.forward); //前后移动
        float curSpeed = speed * Input.GetAxis("Vertical");
        characterController.SimpleMove(forward * curSpeed);
        Vector3 v = camer.transform.TransformDirection(Vector3.right); //左右移动
        float vSpeed = speed * Input.GetAxis("Horizontal");
        characterController.SimpleMove(v * vSpeed);

    }
}
